package com.briup.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Map;

@RestController
@RequestMapping("/path")
public class PathController {

    @RequestMapping({"1","冯丽娇组","再见"})
    public String  test1(){
        return "有请下一组";
    }

//    @RequestMapping(value = "/2",method = RequestMethod.GET)
    @GetMapping("/2")
    public String test2(HttpServletRequest request){
        System.out.println(request.getClass());
        System.out.println(request);

        String protocol = request.getProtocol();
        System.out.println("protocol = " + protocol);
        String serverName = request.getServerName();
        System.out.println("serverName = " + serverName);
        int serverPort = request.getServerPort();
        System.out.println("serverPort = " + serverPort);
        String contextPath = request.getContextPath();
        System.out.println("contextPath = " + contextPath);
        String servletPath = request.getServletPath();
        System.out.println("servletPath = " + servletPath);
        Enumeration<String> headerNames = request.getHeaderNames();
      while(headerNames.hasMoreElements())  {
          String name = headerNames.nextElement();
          String value = request.getHeader(name);
          System.out.println(name+":"+value);
      }
      //获取参数

        Map<String, String[]> map = request.getParameterMap();
      map.forEach((k,v)->{
          System.out.println(k+
                  "-" + Arrays.toString(v));
      });
        String name = request.getParameter("name");
        return name+":早点退休";
    }
}
